package com.musollo.mp3tools;

import java.io.File;
import java.io.IOException;

import com.musollo.domain.MP3;

/**
 * This abstract class defines a way to categorize MP3 files. How the MP3's are
 * categorized is up to the implementing class.
 * 
 * @author paw.janssen
 * 
 */
public abstract class AbstractMP3Categorizer {

	private File targetDir;

	/**
	 * Categorize the given MP3 file.
	 * 
	 * @param mp3
	 *            - The mp3 file to categorize.
	 * 
	 * @throws IOException
	 *             Can occur when file cannot be created.
	 */
	public abstract void categorizeMP3(MP3 mp3) throws IOException;

	public File getTargetDir() {
		return targetDir;
	}

	/**
	 * Setter to set the target directory to move the categorized files to.
	 * 
	 * @param target
	 *            - The target, which needs to be a directory.
	 */
	public void setTargetDir(final File target) {
		if (target == null) {
			throw new IllegalArgumentException("Target directory is null");
		}
		if (!target.isDirectory()) {
			throw new IllegalArgumentException("Target is not a directory or does not exist");
		}

		this.targetDir = target;
	}
}
